#ifndef CHARACTER_HH
#define CHARACTER_HH

#include <iostream>
#include <string>
#include <vector>
#include "ICharacter.hh"
#include "Item.hh"

// Basic character class, used for both players and ordinary enemies
class Character : public ICharacter 
{
private:
    std::string name;            // Character name
    std::string description;     // Character description
    unsigned health;             // Current health points
    unsigned maxHealth;          // Maximum health points
    unsigned attackPower;        // Attack, to distinguish from funtion attack()
    unsigned defense;            // Defense power
    
    std::vector<Item*> inventory;// Dynamically managed inventory, storing pointers to Item*
public:
    // Constructor
    Character(const std::string& name, const std::string& description, unsigned health, unsigned attack, unsigned defense);
    Character(const Character& other) = default; // Copy constructor, default implementation is sufficient
    Character& operator=(const Character& other) = default; // Copy assignment operator, default implementation is sufficient
    // Destructor, releases inventory memory
    virtual ~Character();

    //
    // Implement methods of the ICharacter interface
    bool isAlive() const override;
    bool takeDamage(unsigned damage) override;
    bool attack(ICharacter& target) override;

    std::string getName() const override;
    std::string getDescription() const override;
    unsigned getHealth() const override;
    unsigned getAttack() const override;
    unsigned getDefense() const override;
    std::string toString() const override;

    void addToInventory(Item* item) override;
    void displayInventory() const override;
    void display() const override;

    // Operator overloading, allows adding items to the inventory using "+="
    Character& operator+=(Item* item);

    // Operator overloading: uses "-" as an attack operation, calls the attack method
    bool operator-(ICharacter& target);
};

#endif
